All Questions
17 questions
4votes
2answers
489views
C bit mask calculator written using GTK+ 3
I've been studying C on my own using K&R 2nd Edition, and started exploring GTK+ to practice some of the concepts I've learned by making GUI applications. This is the first GUI application I've ...
2votes
1answer
306views
C++ class for a flag register in a Chip8 emulator
In order to learn C++ I decided to code a Chip8 emulator following a tutorial. When I came across the idea of a flag register and decided it would be fun to implement in order to get familiar with ...
3votes
1answer
240views
K&R Exercise 2-6 : Inserting part of a bitset into another
"Inserting" part of a bitset into another This is Exercise 2-6 on the K&R book, 2nd edition. The reader is asked to: Write a function setbits(x,p,n,y) that returns x with the n bits that begin ...
5votes
3answers
2kviews
Reading/writing single bits from/to FILE
I'm implementing a Huffman encoding/decoding program and I need a way to deal with single bits. I tried to keep things as simple as possible, I "pack" bits inside a single byte and I have only one ...
11votes
4answers
27kviews
Find the binary gap of a number N
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of ...
15votes
2answers
1kviews
Program that guesses your number using bitwise operations
I got the idea for this program from this site. functions.cpp: ...
8votes
1answer
29kviews
Start an EventHandler in different Thread
I just stumbeled accross some code and I would do it in a different way. Since I am quite new to programming, I just wanted to know if I understand it right. Original Code: ...
5votes
2answers
588views
K&R 2-7 - Invert a bitfield from a number
This is my solution to the Exercise 2-7 of K&R C book. The assignment is: Write a function invert(x,p,n) that returns x ...
6votes
6answers
20kviews
A simple assembly program to count the number of ones in a register
I made a simple assembly program to count the number of ones in a register. Since this is basically my first ever, I would like to hear what I can improve or if there are some major flaws in this one: ...
1vote
1answer
172views
Using JavaScript-bitwise AND and -bitwise NOT for setting a number to 0
Obviously is the XOR-operator is used in low-level programming-languages used a lot for setting a value back to all bits 0. For example: 11010 ^ 11010 => 00000 Brought my teacher to figuring a out ...
4votes
1answer
227views
LEB128 in Haskell
I have implemented the LEB128 encoding for unsigned integers. I'm fairly new to Haskell so I have some doubt about the coding style I'm using, particularly the definition of ...
7votes
1answer
331views
Calculating the results of bit operations
I have a simple program that calculates and outputs the results of all the bit operators. I'm planning to send it to my friend and to explain some stuff about them to him. Before I do that, I want to ...
5votes
2answers
8kviews
Binary to decimal number converter
Here I am doing some exercises for my studies with Python. This is a binary to decimal number converter (currently restricted to that). These are the very first steps, so there is no error handling. ...
4votes
4answers
337views
BitShift code compacting
I'm new to Java programming and am really enjoying it. I made a bitshift program, but I think it's too long. I expect the program to: Let users input the number and degree to be shifted Specify if it ...
2votes
2answers
421views
Displaying data as binary in C with bitmasks
I wrote a program to display data in memory as binary and it worked. (It gave me immense sense of satisfaction and joy to see this work. I guess this happens to newbies who are just testing the waters)...